package keke.ai.code.mother.handle.security;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import keke.ai.code.mother.common.BaseResponse;
import keke.ai.code.mother.common.ResultUtils;
import keke.ai.code.mother.exception.ErrorCode;
import keke.ai.code.mother.util.WriteJson;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

/**
 * 无权限处理
 */
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) {
        BaseResponse<?> error = ResultUtils.error(ErrorCode.NO_AUTH_ERROR);
        WriteJson.writeJson(request, response, error);
    }
}
